package linker.window;

import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import linker.list.Model;

/**
 * 
 * @version linker 0.93
 * @author Jianfeng jianfeng.linker@gmail.com
 * 
 */

class FilterField extends JTextField implements DocumentListener {

	private static final long serialVersionUID = 1L;

	private JList list;

	public FilterField(int width, JList list) {
		super(width);
		
		getDocument().addDocumentListener(this);
		
		this.list = list;
	}

	public void changedUpdate(DocumentEvent e) {
		((Model) list.getModel()).refilter(getText());
	}

	public void insertUpdate(DocumentEvent e) {
		((Model) list.getModel()).refilter(getText());
	}

	public void removeUpdate(DocumentEvent e) {
		((Model) list.getModel()).refilter(getText());
	}
}
